﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/MasterPage.Master" AutoEventWireup="true" CodeBehind="AddBill.aspx.cs" Inherits="DrivingCRM.Views.Private.CRM.AddBill" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="banniere" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="nav" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="contenu" runat="server">
    <asp:EntityDataSource ID="DS_Packages" runat="server" 
        ConnectionString="name=Model_DrivingCRMContainer" 
        DefaultContainerName="Model_DrivingCRMContainer" EnableFlattening="False" 
        EntitySetName="PackageSet1" EntityTypeFilter="Package">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="DS_Products" runat="server" 
        ConnectionString="name=Model_DrivingCRMContainer" 
        DefaultContainerName="Model_DrivingCRMContainer" EnableFlattening="False" 
        EntitySetName="ProductSet" EntityTypeFilter="Product">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="DS_Clients" runat="server" 
        ConnectionString="name=Model_DrivingCRMContainer" 
        DefaultContainerName="Model_DrivingCRMContainer" EntitySetName="UserSet" 
        EntityTypeFilter="Client" Select="it.[Id], it.[CompleteName]">
    </asp:EntityDataSource>

    <h2>Edition d'une facture utilisateur</h2>

    <table>
        <tr>
            <td>Client:</td>
            <td>
                <asp:DropDownList ID="DDL_Clients" runat="server" DataSourceID="DS_Clients" 
                    DataTextField="CompleteName" DataValueField="Id">
                </asp:DropDownList>
            </td>
        </tr>
    </table>

    <br />
    <br />

    <table style="width:100%">
        <caption style="font-size:12px;">Facture du <%= string.Format("{0:dd/MM/yyyy}",DateTime.Now) %></caption>
        <tr>
            <td>Prestation</td>
            <td>Quantité</td>
            <td>Prix</td>
        </tr>
                
        <asp:UpdatePanel ID="UP_Bill" runat="server">
            <ContentTemplate>
                <tr>
                    <td colspan="3">Paquetages</td>
                </tr>
                <% int count = 0;
                    foreach (DrivingCRM.Model.Package pack in this.packages)
                    {%>
                <tr>
                    <td>
                        <%= pack.Name %></td>
                    <td>
                        <%= this.productsQuantity[count] %>
                    </td>
                    <td>
                                
                    </td>
                </tr>
                <%  count++;
                    } %>
            </ContentTemplate>
        </asp:UpdatePanel>
    </table>  
    
    <br /><br />

    <table>
        <caption>Ajout d'une prestation</caption>
        <tr>
            <td>Quantité à ajouter</td>
            <td>Prestation à ajouter</td>
            <td></td>
        </tr>
        <tr>
            <td>
                <asp:TextBox ID="TB_QuantityPackage" runat="server"></asp:TextBox>
            </td>
            <td>
                <asp:DropDownList ID="DDL_Packages" runat="server" DataSourceID="DS_Packages" 
                    DataTextField="Name" DataValueField="IdPackage">
                </asp:DropDownList>
            </td>
            <td>
                <asp:Button ID="B_AddPackage" runat="server" Text="Ajouter le package" 
                    onclick="B_AddPackage_Click" />
            </td>
        </tr>
        <tr>
            <td>
                <asp:TextBox ID="TB_QuantityProduct" runat="server"></asp:TextBox>
            </td>
            <td>
                <asp:DropDownList ID="DDL_Products" runat="server" DataSourceID="DS_Products" 
                    DataTextField="Name" DataValueField="IdProduct">
                </asp:DropDownList>
            </td>
            <td>
                <asp:Button ID="B_AddProduct" runat="server" Text="Ajouter le produit" 
                    onclick="B_AddProduct_Click" />
            </td>
        </tr>
        <tr>
            <td colspan="3"><asp:Label ID="L_ErrorMessage" runat="server" ForeColor="Red" /> </td>
        </tr>
    </table>

    <br />

    <table>
        <tr>
            <td>
                <asp:Button ID="B_Return" runat="server" Text="Retour vers l'accueil" />
            </td>
            <td>
                <asp:Button ID="B_Vadidate" runat="server" Text="Valider la facture" />
            </td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="footer" runat="server">
</asp:Content>
